<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no viewport-fit=cover" />
		<link rel="stylesheet" type="text/css" href="../../Common/css/ufun.css" />
		<script src="../js/settings.js"></script>
		<script src="../../Common/js/jump.js"></script>
		<script src="../../Common/js/tools.js"></script>
		<script type="text/javascript" src="../../Common/js/lib/jquery-3.4.1.min.js"></script>
		<link rel="stylesheet" href="../../Common/css/lib/materialize.min.css">
		<script src="../../Common/js/lib/materialize.min.js"></script>
		<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
		<style type="text/css">
			html {
				background-color: var(--color-gray-white);
			}
			
			#NickInput {
				height: 20vw;
				width: calc(100% - 10vw);
				margin: 5vw;
				padding: 2vw;
				position: relative;
				border: 0;
				outline: none;
				border-radius: 5vw;
				color: black;
				text-align: center;
				background-color: var(--color-white) !important;
			}
			
			input:focus {
				box-shadow: 0px 0px 5px var(--color-yellow) !important;
			}
			
		</style>
	</head>
	<body>
		<!-- 标题栏 -->
		<header>
			<div id="Left" class="com-btn" onmouseup="ThisClose();">
				<i class="material-icons">keyboard_arrow_left</i>
			</div>
			<p id="Title">设置昵称</p>
			<div id="Right" class="com-btn" onmouseup="submitNick();">
				提交
			</div>
		</header>
		
		<div class="content">
			<input class="textbox" type="text" placeholder="昵称" id="NickInput" data-length="12" maxlength="12">
		</div>

		<script>
			var Current;
			var userHash;
			var nickInput = ID('NickInput');

			document.addEventListener('plusready', function() {
				GetStatusTop();
				Current = plus.webview.currentWebview();
				userHash = plus.storage.getItem('userHash');
				nickInput.value = Current.lastNick;
				DoShow(Current);
			});

			function submitNick() {
				if (CheckLength('昵称', nickInput.value, 8, 0)) {
					CallAJAX('setNick', {
						'userHash': userHash,
						'nick': nickInput.value,
					}, function() {
						alert('修改成功');
						ThisBack();
					}, function() {
						alert('修改失败');
						ThisBack();
					});
				}
			}
		</script>
	</body>
</html>
